import WebSocket from "ws";

export class WebSocketClientMain {
    private _client: WebSocket;
    constructor() {
        this._client = new WebSocket('ws://localhost:3001');
        this._client.on('message', this.onMsg.bind(this));
        this._client.on('open', () => {
            console.log('连接成功')
            this._client.send('你看看我！！')
        });
    }

    private onMsg(self: WebSocket, data: WebSocket.Data) {
        console.log(data)
    }
}

new WebSocketClientMain();